// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0.
// See the LICENCE file in the repository root for full licence text.

.comment {
  @_avatar-margin: 10px;
  @_avatar: 40px;
  @_line-width: 5px;
  @_line-margin: 10px;
  @_top: comment;
  @_spacing: 10px;
  @_gutter-desktop-left: @gutter-v2-desktop;
  @_gutter-desktop-right: @gutter-v2-desktop;

  margin-top: @_spacing;
  font-size: @font-size--normal-2;
  border-bottom: 0 solid var(--comments-separator-bg);
  position: relative;

  &--top {
    border-bottom-width: 1px;
    margin-top: 0;
    padding: (@_spacing + 5px) @gutter-v2;

    .@{_top}--single& {
      border-bottom-width: 0;
    }

    &:last-of-type {
      border-bottom-width: 0;
    }

    @media @desktop {
      padding-left: @_gutter-desktop-left;
      padding-right: @_gutter-desktop-right;
    }
  }

  &__action {
    .reset-input();
    .link-default();
    text-transform: lowercase;
    color: @osu-colour-f1;
    .link-hover({ color: white });

    &:hover {
      text-decoration: underline;
    }

    &--active {
      color: @osu-colour-l1;
    }
  }

  &__avatar {
    width: @_avatar;
    height: @_avatar;
    margin-right: @_avatar-margin;
    flex: none;
  }

  &__commentable-meta {
    margin-left: (@_avatar + @_avatar-margin);
    margin-bottom: 5px;
    font-size: @font-size--small-2;
    display: flex;
    align-items: baseline;

    .@{_top}--single & {
      margin-left: 0;
      margin-bottom: 30px;
      flex-direction: column;
      font-size: @font-size--title;
    }
  }

  &__commentable-meta-icon {
    font-size: 0.9em;
    margin-right: 5px;
  }

  &__commentable-meta-type {
    background-color: @osu-colour-b6;
    padding: 5px 15px;
    margin-right: 5px;
    border-radius: 10000px;
    font-size: @font-size--normal;

    .@{_top}--single & {
      margin-bottom: 10px;
    }
  }

  &__container {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
  }

  &__deleted {
    font-weight: bold;
    margin: 10px 0;
  }

  &__editor {
    padding: 10px 0;
  }

  &__float-container {
    position: absolute;
    height: @_avatar;
    top: 0;
    display: flex;
    align-items: center;
    padding: 0 5px;

    &--left {
      justify-content: flex-end;
      left: -@_gutter-desktop-left;
      width: @_gutter-desktop-left;

      .@{_top}--top > & {
        left: 0;
      }
    }

    &--right {
      justify-content: flex-start;
      right: -@_gutter-desktop-right;
      width: @_gutter-desktop-right;

      .@{_top}--top > & {
        right: 0;
      }
    }
  }

  &__main {
    display: flex;
    position: relative;

    &--deleted {
      opacity: 0.5;
    }
  }

  &__message {
    margin: 2px 0;

    .@{_top}__main--clip & {
      height: calc(var(--line-height) * var(--clip-lines));
      overflow: hidden;
      position: relative;

      &::after {
        display: block;
        content: "";
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        height: calc(var(--line-height) * 3);
        background-image: linear-gradient(
          to bottom,
          hsla(var(--comments-bg-hsl), 0),
          hsl(var(--comments-bg-hsl))
        );
        pointer-events: none;
      }
    }
  }

  &__owner-badge {
    background-color: @osu-colour-l1;
    color: @osu-colour-b6;
    font-weight: bold;
    font-size: @font-size--small;
    bottom: 2px;
    padding: $bottom 5px;
    border-radius: 10000px;
  }

  &__replies {
    margin-top: 10px;

    &--hidden {
      display: none;
    }

    &--indented {
      padding-left: 0;

      @media @desktop {
        padding-left: 20px;
      }
    }
  }

  &__reply-box {
    padding-top: 10px;
  }

  &__row {
    gap: 4px;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    font-weight: 600;

    &--footer {
      color: @osu-colour-f1;
      font-size: @font-size--normal;
      column-gap: 10px;

      a {
        color: @osu-colour-f1;
        .link-hover({ color: white });
      }
    }

    &--header {
      font-size: @font-size--title-small;
    }
  }

  &__row-item {
    &--info {
      font-weight: normal;
    }

    &--pinned {
      .fa {
        vertical-align: middle;
      }
    }

    &--replies {
      width: 100%;
    }
  }

  &__toggle-clip {
    .reset-input();
    width: max-content;
    color: @osu-colour-l2;
    padding: 5px 0;

    .link-hover({
      color: @osu-colour-l1;
    });
  }

  &__toolbar {
    margin: 10px 0;
    display: flex;
    justify-content: flex-end;
  }

  &__top-show-replies {
    .reset-input();
    width: @_avatar;
    font-size: 18px; // icon size
    display: none;
    color: @osu-colour-f1;

    @media @desktop {
      display: block;

      .@{_top}--single & {
        display: none;
      }
    }
  }
}
